﻿using System.Diagnostics;
using System.IO;
using dnpCryptCompress;

namespace cryptv2
{
  public class Decrypt
  {
    public static void File(string sourceFilename, string targetFilename, string password)
    {
      Trace.TraceInformation("Decrypt {0} with password {1}", sourceFilename, password);
      var returnMessage = new CryptCompress().FileDecrypt(sourceFilename, password);

      Trace.TraceInformation("Decrypt call returned with message {0}", returnMessage);

      var cryptedFileName = Path.Combine(Path.GetDirectoryName(sourceFilename), Path.GetFileNameWithoutExtension(sourceFilename));

      Trace.TraceInformation("Move {0} to {1}", cryptedFileName, targetFilename);
      System.IO.File.Move(cryptedFileName, targetFilename);
    }
  }
}
